"""
调试应用启动问题
"""
import traceback

try:
    print("1. 导入基础模块...")
    from fastapi import FastAPI
    print("✅ FastAPI导入成功")
    
    print("2. 导入配置...")
    from app.core.config import settings
    print("✅ 配置导入成功")
    
    print("3. 导入数据库...")
    from app.core.database import register_database
    print("✅ 数据库模块导入成功")
    
    print("4. 导入Redis...")
    from app.utils.redis_client import init_redis, close_redis
    print("✅ Redis模块导入成功")
    
    print("5. 导入API模块...")
    from app.api import cargo, tracking, websocket, auth
    print("✅ API模块导入成功")
    
    print("6. 导入主应用...")
    from app.main import app
    print("✅ 主应用导入成功")
    
    print("7. 检查应用配置...")
    print(f"应用名称: {app.title}")
    print(f"应用版本: {app.version}")
    print(f"调试模式: {settings.debug}")
    print(f"数据库URL: {settings.database_url}")
    print(f"Redis URL: {settings.redis_url}")
    
    print("\n🎉 所有模块导入成功！应用程序配置正常。")
    
except Exception as e:
    print(f"\n❌ 导入失败: {e}")
    print("\n详细错误信息:")
    traceback.print_exc()
